<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<title>分组查询</title>

</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 设备管理 <span class="c-gray en">&gt;</span> 分组查询 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
			<a class="btn btn-primary radius" onclick="group_add('添加分组','jsp/managegroup/addDeviceGroup.jsp')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加分组</a></span> 
		<span class="r">共有数据：<strong>${total}</strong>条</span> 
	</div>
	<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="80">设备ID</th>
					<th width="80">comment</th>
					<th width="80">status</th>
					<th width="80">major</th>
					<th width="80">minor</th>
					<th width="80">uuid</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="list" items="${list}">
					<tr class="text-c">
						<td><input type="checkbox" value="${list.deviceId}" name=""></td>
						<td>${list.deviceId}</td>
						<td>${list.comment}</td>
						<td>${list.status}</td>
						<td>${list.major}</td>
						<td>${list.minor}</td>
						<td>${list.uuid}</td>
						<td class="f-14 td-manage">
							<a style="text-decoration:none" class="ml-10" onClick="group_edit('编辑分组','jsp/managegroup/editDeviceGroup.jsp','${groups.group_id}','${groups.group_name}')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
							<a style="text-decoration:none" class="ml-10" onClick="group_del(this,'${groups.group_id}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script> 
<script type="text/javascript" src="lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript">
$('.table-sort').dataTable({
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,7]}// 制定列不参与排序
	]
});

/*分组-添加*/
function group_add(title,url,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		shadeClose: true,
	    shade: 0.8,
	    area: ['630px', '360px'],
		content: url
	});
// 	layer.full(index);
}

function group_del(obj,group_id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax( {
			type : "GET",
			contentType:"application/json",
			dataType : 'json',
			url: "deleteIbeaconGroup",
			data: { group_id: group_id},
			async: true,
			success : function(ret) {
				var result = ret.errmsg;
				if("success." == result){
					location.replace(location.href);
				}
			}
			})
		layer.msg('已删除!',{icon:1,time:1000});
	});
	
}

/*分组-添加*/
function group_edit(title,url,group_id,group_name){
	var url = url+'?group_id='+group_id+"&group_name="+group_name;
	var index = layer.open({
		type: 2,
		title: title,
		shadeClose: true,
	    shade: 0.8,
	    area: ['630px', '360px'],
		content: url
	});
// 	layer.full(index);
}

/**
 * 分组-批量删除
 */
function datadel(){
	layer.confirm('确认要删除吗？',function(index){
		var groupIds = "";
		$("input[type='checkbox']").each(function(){
			if($(this).is(':checked')){
				var  groupId=  $(this).val();
				groupIds = groupIds +groupId+","
			}
		})
		groupIds = groupIds.substring(0,groupIds.length);
		
		$.ajax( {
			type : "GET",
			contentType:"application/json",
			dataType : 'json',
			url: "deleteIbeaconGroups",
			data: { groupIds: groupIds},
			async: true,
			success : function(ret) {
				location.replace(location.href);
				
			}
			})
		layer.msg('已删除!',{icon:1,time:1000});
	});
	
}


</script> 
</body>
</html>